package com.shanghaiyimu.yimiyangche.fragment;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.shanghaiyimu.yimiyangche.R;
import com.shanghaiyimu.yimiyangche.adapter.ErshoucheAdapter;
import com.shanghaiyimu.yimiyangche.bean.CarBean;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class ErshouCheFragment extends Fragment {


    public ErshouCheFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_ershou_che, container, false);
        initView(view);
        initData();
        return view;
    }

    private void initData() {
        for (int i = 0; i < 15; i++) {
            CarBean carBean = new CarBean("奔驰"+i,56+i+" - "+98.63+i,i+48);
            datas.add(carBean);
        }
        adapter.notifyDataSetChanged();
    }

    private ListView mListView;
    private ErshoucheAdapter adapter;
    private List<CarBean> datas = new ArrayList();
    private void initView(View view) {
        mListView = (ListView) view.findViewById(R.id.lv_ershouche);
        adapter = new ErshoucheAdapter(datas,getContext());
        mListView.setAdapter(adapter);
    }

}
